//
//  CYWorksManagementViewController.m
//  cyydt
//
//  Created by chu on 2019/1/21.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYWorksManagementViewController.h"
#import "CYWorksManagementTableViewCell.h"

#import "CYWorksMyVideoViewController.h"
#import "CYWorksMyArcitleViewController.h"

@interface CYWorksManagementViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation CYWorksManagementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"作品管理";
    [self.view addSubview:self.tableView];
    if (@available(iOS 11.0, *)) {
        self.tableView.estimatedSectionFooterHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else{
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CYWorksManagementTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CYWorksManagementTableViewCell"];
    if (!cell) {
        cell = [[NSBundle mainBundle] loadNibNamed:@"CYWorksManagementTableViewCell" owner:self options:nil][0];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    if (indexPath.row == 0) {
        cell.headImageView.image = [UIImage imageNamed:@"zpgl_wz"];
        cell.upLabel.text = @"我的文章";
        cell.bottomLabel.text = @"发布你的长文章";
    }else{
        cell.headImageView.image = [UIImage imageNamed:@"zpgl_sp"];
        cell.upLabel.text = @"我的视频";
        cell.bottomLabel.text = @"发布你的视频";
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 90;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.00001f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        CYWorksMyArcitleViewController *work = [[CYWorksMyArcitleViewController alloc] init];
        [[AppDelegate sharedAppDelegate] pushViewController:work];
    }else{
        CYWorksMyVideoViewController *work = [[CYWorksMyVideoViewController alloc] init];
        [[AppDelegate sharedAppDelegate] pushViewController:work];
    }
}

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kWindowW, kWindowH - Height_NavBar) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = BackGroundColor;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerNib:[UINib nibWithNibName:@"CYWorksManagementTableViewCell" bundle:nil] forCellReuseIdentifier:@"CYWorksManagementTableViewCell"];
        
    }
    return _tableView;
}


@end
